package com.gomtel.smartdevice.ui.dialog;

import android.content.Context;
import android.support.annotation.StyleRes;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;

import com.gomtel.smartdevice.R;
import com.gomtel.smartdevice.base.WatchBaseDialog;
import com.gomtel.smartdevice.bean.AbourAllTypeBean;
import com.gomtel.smartdevice.moudle.event.CommonEvent;
import com.gomtel.smartdevice.moudle.event.EventCode;
import com.gomtel.smartdevice.moudle.rxtools.EventBusUtil;
import com.gomtel.smartdevice.utils.SystemUtil;
import com.gomtel.smartdevice.utils.ToastUtil;

import butterknife.BindView;


/**
 * Created by Administrator on 2018/3/21.
 */

public class BPCDialog extends WatchBaseDialog implements View.OnClickListener {

    private Context context;
    private int pvh;
    private int ldo;
    @BindView(R.id.btn_cancle)
    Button btn_cancle;
    @BindView(R.id.btn_commit)
    Button btn_commit;
    @BindView(R.id.input_pvh)
    EditText input_pvh;
    @BindView(R.id.input_ldo)
    EditText input_ldo;

    protected BPCDialog(Context context, @StyleRes int themeResId, int pvh, int ldo) {
        super(context, themeResId);
        this.context = context;
        this.pvh = pvh;
        this.ldo = ldo;
    }

    @Override
    protected int getLayout() {
        return R.layout.dialog_bpc;
    }

    @Override
    protected void initClass() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initListener() {
        btn_cancle.setOnClickListener(this);
        btn_commit.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_cancle:
                EventBusUtil.sendEvent(new CommonEvent(EventCode.ACTION_BPC_OFF));
                dismiss();
                break;
            case R.id.btn_commit:
                boolean empty = input_pvh.getText().toString().isEmpty();
                boolean empty1 = input_ldo.getText().toString().isEmpty();
                if (!empty && !empty1) {
                    EventBusUtil.sendEvent(new CommonEvent(EventCode.ACTION_BPC, new AbourAllTypeBean(input_pvh.getText().toString(), input_ldo.getText().toString())));
                } else {
                    new ToastUtil(context).showToast("请填写完整！");
                }
                dismiss();
                break;
        }
    }


    @Override
    protected void onDismissListener() {
        super.onDismissListener();
        SystemUtil.windowToLight(context);
    }


}
